package com.roc.template.config;

import com.roc.template.interceptor.SimpleAuthenticationInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import javax.annotation.Resource;
import java.util.Arrays;
import java.util.List;

/**
 * 与filter比较是，这个交由spring管理
 */
@Configuration
public class WebAppconfigurer implements WebMvcConfigurer {
    @Resource
    private SimpleAuthenticationInterceptor simpleAuthenticationInterceptor;

    //加入拦截器
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        List<String> exclueUrls= Arrays.asList("/webjars/**","/swagger-ui.html","/swagger-resources/**","/v2/api-docs**");
        registry.addInterceptor(simpleAuthenticationInterceptor).excludePathPatterns(exclueUrls);
    }
}
